package com.nets.pool;

import com.nets.server.Server;
import com.nets.util.LogUtil;
import com.nets.util.XmlParser;

/**
 * @author sig
 * @since 2016/9/17
 */
public class ServerPool {
    private static Server server;

    public static int serverId;
    public static String serverName;
    public static String serverIp;
    public static int serverPort;

    public static boolean startupFinish;
    public static boolean logSwitch = true;

    public static void setServer(Server s) {
        server = s;
    }

    public static void init() {
        XmlParser parser = new XmlParser("config/server.xml");
        serverId = parser.getInt("serverId");
        serverName = parser.getString("serverName");
        serverIp = parser.getString("serverIp");
        serverPort = parser.getInt("serverPort");
        LogUtil.console.info("The server pool has been initialized.");
    }

    public static void shutdown() {
        if (null != server) server.shutdown();
    }
}
